package com.haiertvbic.tvnow.util;

import com.haiertvbic.tvnow.db.InitAppDataBase;
import com.haiertvbic.tvnow.testblock.Function;
import com.oem.InfoService;

import android.app.Activity;
import android.content.Context;

public class InitApplication {

	public static void initParmas(Activity context) {
		String md5mac = getDeviceMac(context);
		Constant.MAC = new MacAddress().Md5(md5mac, "32");
		Constant.TvPlatform = getTvPlatform(context);

		InitAppDataBase initAppDataBase = new InitAppDataBase();
		if (!initAppDataBase.isDBExist(context)) {
			initAppDataBase.copyDBFile(context);
		}

		Function.initFunctionData(context);
	}

	public static String getDeviceMac(Context context) {
		String md5mac = null;
		MacAddress macInfo = new MacAddress();
		if (md5mac == null) {
			// 得到的就是大写的去：号的
			md5mac = macInfo.getMacAddress(context);
		}
		return md5mac;
	}

	/**
	 * 得到平台号
	 * 
	 * @param context
	 * @return
	 */
	public static String getTvPlatform(Context context) {
		InfoService is = new InfoService(context);
		String chipType = is.getValueByKey("ChipPlatform");// ChipPlatform
		return chipType;
	}
}
